package org.oaix.enmus;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Locale;

/**
 * 需要推送的表结构
 *
 * @author: wanghoukun
 * @date: 2023-11-17 14:20
 **/
@Getter
public enum PushTablesEnum {

    AI_ACTION_WARN("ai_action_warn", "old_data_to_busi", "device_data", true, "default"),
    AI_DEVICE("ai_device", "old_data_to_busi", "device_data", true, "default"),
    MESSAGE_DATA("message_data", "old_data_to_busi", "device_data", true, "default"),
    MESSAGE_DATA_FK("message_data_fk", "old_data_to_busi", "device_data", true, "default"),
    MONITOR_BRANCH("monitor_branch", "old_data_to_busi", "device_data", true, "default"),
    MONITOR_NODE("monitor_node", "old_data_to_busi", "device_data", true, "default"),
    WK_WARN_RECORD("wk_warn_record", "old_data_to_busi", "device_data", true, "default"),
    WK_NODE("wk_node", "old_data_to_busi", "device_data", true, "default"),
    WK_RECORD("wk_record", "old_data_to_busi", "device_data", false, "default"),
    WK_RECORD_TO_MACHINE_SERVER("wk_record", "old_data_to_machine_server", "device_data", false, "dataCenter"),
    STOCK("stock", "old_data_to_busi", "device_data", true, "default"),
    STOCK_ITEM("stock_item", "old_data_to_busi", "device_data", true, "default"),
    STOCK_WARNING_STAT("stock_warning_stat", "old_data_to_busi", "device_data", true, "default"),
    STOCK_HISTORY_STAMENT("stock_history_stament", "old_data_to_busi", "device_data", true, "default"),
    STOCK_HISTORY_LATEST("stock_history_latest", "old_data_to_busi", "device_data", true, "default"),
    FEEDBACK_RECORD("feedback_record", "old_data_to_busi", "device_data", true, "default"),
    RISK_WARN_RESULT("risk_warn_result", "old_data_to_busi", "device_data", true, "default"),
    CANTEEN_BASE_DATA("canteen_base_data", "old_data_to_busi", "common_data", true, "dataCenter"),
    ORGANIZATION_LABEL_DATA("organization_label_data", "old_data_to_busi", "common_data", true, "dataCenter"),
    ORGANIZATION_IMG("organization_img", "old_data_to_busi", "common_data", true, "dataCenter"),
    PARTNERSHIP_DATA("partnership_data", "old_data_to_busi", "common_data", true, "dataCenter"),
    PERSON_DATA("person_data", "old_data_to_busi", "common_data", true, "dataCenter"),
    DEPARTMENT_ORGANIZATION("department_organization", "old_data_to_busi", "common_data", true, "dataCenter"),
    TEAM_GROUP("team_group", "old_data_to_busi", "common_data", true, "dataCenter"),
    DUTY_ORGANIZATION("duty_organization", "old_data_to_busi", "common_data", true, "dataCenter"),
    SAFETY_USER_DATA("safety_user_data", "old_data_to_busi", "common_data", true, "dataCenter"),
    SAFETY_GROUP("safety_group", "old_data_to_busi", "common_data", true, "dataCenter"),
    ADDITIVE("additive", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    ADDITIVE_FOOD("additive_food", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    BILL_PESTICIDES("bill_pesticides", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    ADDITIVE_LEDGER("additive_ledger", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    PEOPLE_MORNING_INSPECTION("people_morning_inspection", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    PEOPLE_MORNING_INSPEC_INFO("people_morning_inspec_info", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    SAMPLE("sample", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    BILL_LEFTOVERS("bill_leftovers", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    BILL_LEFTOVERS_DISHES("bill_leftovers_dishes", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    WAREHOUS_CG("warehous_cg", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    WAREHOUS_CG_DTL("warehous_cg_dtl", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    WAREHOUS_DETAIL("warehous_detail", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    BILL_WASTE("bill_waste", "old_data_to_busi", "ledger_data", true, "dataCenter"),
    DFTION_AIR("dftion_air", "old_data_to_busi", "ledger_data", true, "config1"),               // 空气消毒台账(电子数据)
    DFTION_PROJECT("dftion_project", "old_data_to_busi", "ledger_data", true, "config1"),       // 餐具消毒台账(电子数据)

    DFTION_AIR_INTELLIGENT("dftion_air_intelligent", "old_data_to_busi", "ledger_data", true, "config1"),               // 空气消毒台账(智能数据)
    DFTION_PROJECT_INTELLIGENT("dftion_project_intelligent", "old_data_to_busi", "ledger_data", true, "config1"),       // 餐具消毒台账(智能数据)


    //日周月
    DAY_CHECK_RESULT("day_check_result", "old_data_to_busi", "data_manage", true, "dataCenter"),
    DAY_CHECK_RESULT_INFO("day_check_result_info", "old_data_to_busi", "data_manage", true, "dataCenter"),
    WEEK_CHECK("week_check", "old_data_to_busi", "data_manage", true, "dataCenter"),
    MONTH_CHECK("month_check", "old_data_to_busi", "data_manage", true, "dataCenter"),
    MONTH_CHECK_CENSUS("month_check_census", "old_data_to_busi", "data_manage", true, "dataCenter"),
    MONTH_TRAIN_CENSUS("month_train_census", "old_data_to_busi", "data_manage", true, "dataCenter"),
    ORG_OPERATING_STATUS_CALENDAR("org_operating_status_calendar", "old_data_to_busi", "data_manage", true, "dataCenter"),
    DAY_CHECK_RECORD("day_check_record", "old_data_to_busi", "data_manage", true, "dataCenter"),
    ;

    private final String code;

    private final String instanceCode;

    private final String moduleCode;

    private final boolean syncHistory;

    private final String configName;

    PushTablesEnum(String code, String instanceCode, String moduleCode, boolean syncHistory, String configName) {
        this.code = code;
        this.instanceCode = instanceCode;
        this.moduleCode = moduleCode;
        this.syncHistory = syncHistory;
        this.configName = configName;
    }

    public static PushTablesEnum getByCode(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (PushTablesEnum pushTables : PushTablesEnum.values()) {
            if (code.equals(pushTables.name().toLowerCase(Locale.ROOT))) {
                return pushTables;
            }
        }
        return null;
    }
}
